//
//  UIView+AddGradientLayer.m
//  MengLiao
//
//  Created by xiuxin on 2022/7/15.
//  Copyright © 2022 BaseBusiness. All rights reserved.
//

#import "UIView+AddGradientLayer.h"

@implementation UIView (AddGradientLayer)

- (CALayer *)zh_addGradientLayerWithColorArr:(NSArray *)colorArr
                                   locaitons:(NSArray *)locations
                                  startPoint:(CGPoint )startPoint
                                    endPoint:(CGPoint )endPoint
{
    CAGradientLayer *gradientLayer = [CAGradientLayer layer];
    gradientLayer.colors = colorArr;
    if (locations && locations.count) {
        gradientLayer.locations = locations;
    }
    gradientLayer.startPoint = startPoint;
    gradientLayer.endPoint = endPoint;
    gradientLayer.frame = self.bounds;
    [self.layer insertSublayer:gradientLayer atIndex:0];
    
    return gradientLayer;
}

@end
